define(function(require) {
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
	require("cordova!com.justep.cordova.plugin.qq");
	require("cordova!com.justep.cordova.plugin.weixin.v3");
	var Model = function() {
	    this.thumb = "http://www.xjzlhy.com:81";
	    this.decription = '';
	    this.title = '';
		this.callParent();
	};

	


	Model.prototype.model1ParamsReceive = function(event){
	    var me =  this;
		var titleId = this.getIDByXID("title");
		var contentId = this.getIDByXID("content");
		var titleBar = this.comp("titleBar");
		var panelId = this.getIDByXID("panel1");
		
		if(this.getContext().getRequestParameter('id')){
			var newId = this.getContext().getRequestParameter('id');
    	     var newsUrl = "http://www.xjzlhy.com:81/ex_community/a/api/community/getNewsById?callback=?";
    	     $.getJSON(newsUrl,{id:newId},function(data){
    	    	 if(data && data.data){
    	    		  var id = me.getIDByXID("shareButton");
		    		  $("#"+id).show();
		    	      titleBar.set("title","新闻内容");
		    	      me.thumb += data.data.image;
					  me.decription = data.data.description;
					  me.title = data.data.title;
					  
					  $("#"+titleId).text(data.data.title);
					  $("#"+contentId).html(data.data.content);
					  $("#"+panelId).show();
    	    	 }     
    	     });
		
		}else if(this.getContext().getRequestParameter('hotId')){
			 var hotId = this.getContext().getRequestParameter('hotId');
    	     var hotUrl = "http://www.xjzlhy.com:81/ex_community/a/api/community/getHomeInformationDetailById?callback=?";
    	     $.getJSON(hotUrl,{id:hotId},function(data){
    	    	 if(data && data.data){
    	    	      
    	    		  var id = me.getIDByXID("shareButton");
		    		  $("#"+id).show();
		    	      titleBar.set("title","最新资讯");
		    	      me.thumb += data.data.image;
					  me.decription = data.data.description;
					  me.title = data.data.title;
					  
					  $("#"+titleId).text(data.data.title);
					  $("#"+contentId).html(data.data.classifiedInfoData.content);
					  $("#"+panelId).show();
    	    	 }     
    	     });	
		}else{
		
			switch(event.params.type){
	    	
		    	case "flow":
		    		titleBar.set("title","办事流程");
			       
		    	break;
		    	
		    	case "trends":
		    	   titleBar.set("title","工作动态");
		    	break;
		    	
		    	case "service":
		    		titleBar.set("title","生活服务");
		    	break;
		    	case "notify":
		    	    titleBar.set("title","社区公告");
		    	break;
		    	case "regulation":
		    		titleBar.set("title","政策法规");
		    	break;
		    	case 'area':
		    		titleBar.set('title','物业通知');
		    	break;
		    
		    }
		    
		     $("#"+titleId).text(event.params.title);
			 $("#"+contentId).html(event.params.content);
			 $("#"+panelId).show();
		
		}
	    
	    
	    	
	    
	   
		
		
       // console.log("row",event.params.content);

	};


	Model.prototype.shareButtonClick = function(event){
		this.comp("shareMenu").show();

	};

    Model.prototype.friendCircleClick = function(event){
	    var me = this;
		function success(result) {
			justep.Util.hint("分享成功", {type:'success'});
		}
		function error(result) {
			justep.Util.hint("分享失败", {type:'danger'});
		}
		navigator.weixin.share({
			message : {
				title : me.title,
				description : "朋友圈",
				//mediaTagName : "Media Tag Name(optional)",
				thumb : me.thumb,
				media : {
					//type: navigator.weixin.Type.WEBPAGE, // webpage
					webpageUrl : window.location.href
				// webpage
				}
			},
			scene : navigator.weixin.Scene.TIMELINE
		}, success, error);

	};

	Model.prototype.qqZoneClick = function(event){
	    var me = this;
		function success(result) {
			justep.Util.hint("分享成功", {type:'success'});
	    }
	    function error(result) {
	        justep.Util.hint("分享失败", {type:'danger'});
	    }
	    var args = {};
	    args.url = location.href.split('#')[0];
	    
	    args.title = me.title;
	    args.description = me.decription;
	    //var shareImg = require.toUrl('$UI/communityOto/img/share_icon.png');
	    args.imageUrl = [me.thumb];
	    
	    args.appName = "社区便民服务平台";
	 
	    navigator.QQ.shareToQzone(success, error, args);

	};

	Model.prototype.weixinClick = function(event){
	    var me  = this;
		function success(result) {
			justep.Util.hint("分享成功", {type:'success'});
		}
		function error(result) {
			alert(JSON.stringify(result));
		}
		navigator.weixin.share({
			message : {
				title : me.title,
				description : "分享到微信",
				mediaTagName : "Media Tag Name(optional)",
				thumb : me.thumb,
				media : {
					// type: weixin.Type.WEBPAGE, // webpage
					webpageUrl : window.location.href
				// webpage
				}
			},
			scene : navigator.weixin.Scene.SESSION
		}, success, error);
	};

	Model.prototype.qqClick = function(event){
	    var me = this;
		function success(result) {
			justep.Util.hint("分享成功", {type:'success'});
		}
		function error(result) {
			justep.Util.hint("分享失败", {type:'danger'});
		}
		var args = {};
		
		//args.url = location.href.split('#')[0];
		args.url = location.href;
	    args.title = me.title;
	    args.description = me.decription;
	    //var shareImg = require.toUrl('$UI/communityOto/img/share_icon.png');
	    //alert(shareImg);
	    args.imageUrl = [me.thumb];
	    
	    args.appName = "社区便民服务平台";
		navigator.QQ.shareToQQ(success, error, args);

	};

	return Model;
});
